source torrentpier
{
    type             = mysql
	
    sql_host         = localhost
    sql_user         = root
    sql_pass         = *******
    sql_db           = db_name
    sql_port         = 3306  # optional, default is 3306
    sql_query_pre    = SET CHARACTER_SET_RESULTS=utf8
}

source torrents: torrentpier
{
	sql_query_range  = SELECT MIN(topic_id), MAX(topic_id) FROM bb_topics
    sql_range_step   = 1000

	sql_ranged_throttle = 45

        sql_query = SELECT \
                    t.topic_id, \
                    t.forum_id, \
                    t.topic_title, \
                    t.topic_poster, \
                    t.topic_replies, \
                    t.topic_views, \
                    t.topic_last_post_id,  \
                    r.size/1048576 as size, \
                    r.checked_time, \
                    r.reg_time, \
                    r.seeder_last_seen, \
                    r.complete_count, \
                    s.seeders, s.leechers, \
                    g.speed_up, g.speed_down, \
                    r.tor_type, \
                    r.attach_id \
                FROM \
                    bb_topics t \
                JOIN bb_bt_torrents r on t.topic_id=r.topic_id \
				JOIN bb_bt_tracker g on t.topic_id=g.topic_id \
                LEFT OUTER JOIN bb_bt_tracker_snap s on r.topic_id=s.topic_id \
                WHERE t.topic_id >= $start AND t.topic_id <= $end

    sql_attr_uint   = topic_poster
    sql_attr_uint   = tor_type
    sql_attr_uint   = topic_replies
    sql_attr_uint   = topic_views
    sql_attr_uint   = forum_id
    sql_attr_uint   = topic_last_post_id
    sql_attr_float  = size
    sql_attr_uint   = complete_count
    sql_attr_uint   = attach_id
    sql_attr_uint   = seeders
    sql_attr_uint   = leechers
    sql_attr_uint   = speed_up
    sql_attr_uint   = speed_down
    sql_attr_timestamp       = reg_time
    sql_attr_timestamp       = checked_time
    sql_attr_timestamp       = seeder_last_seen
}

source posts: torrentpier
{
    sql_query_pre       = SET CHARACTER_SET_RESULTS=utf8
    sql_query_pre       = REPLACE INTO sph_counter SELECT 1, MAX(post_id) FROM bb_posts_text

    sql_query_range     = SELECT MIN(post_id), (SELECT max_doc_id FROM sph_counter) FROM bb_posts_text
    sql_range_step      = 1000

	sql_ranged_throttle = 45

        sql_query = SELECT \
                    pt.post_id, \
                    p.poster_id, \
                    p.post_time, \
                    t.topic_id, \
                    t.forum_id, \
                    f.cat_id, \
                    p2.post_time as last_post_in_topic_time, \
                    ph.post_html as text, \
                    t.topic_title as title \
                FROM \
                    bb_posts_text pt \
                INNER JOIN \
                    bb_posts p on p.post_id = pt.post_id \
                INNER JOIN \
                    bb_topics t on p.topic_id = t.topic_id \
                INNER JOIN \
                    bb_posts p2 on t.topic_last_post_id = p2.post_id \
                INNER JOIN \
                    bb_forums f on t.forum_id = f.forum_id \
                INNER JOIN \
                    bb_posts_html ph on ph.post_id = pt.post_id \
                WHERE pt.post_id >= $start AND pt.post_id <= $end

    sql_attr_uint       = last_post_in_topic_time
    sql_attr_uint       = poster_id
    sql_attr_uint       = topic_id
    sql_attr_uint       = forum_id
    sql_attr_uint       = cat_id
    sql_attr_timestamp  = post_time
}

source delta: posts
{
    sql_query_pre               = SET CHARACTER_SET_RESULTS=utf8
    sql_query_range             = SELECT (SELECT max_doc_id FROM sph_counter), MAX(post_id) FROM bb_posts_text
}

index topics
{
    docinfo                     = extern
        morphology              = stem_enru
        stopwords               =
        min_word_len            = 2
        charset_type            = sbcs
        charset_table		= 0..9, A..Z->a..z, _, a..z, U+A8->U+E5, U+B8->U+E5, U+C0..U+DF->U+E0..U+FF, U+E0..U+FF
        enable_star             = 1
        min_prefix_len          = 0
        min_infix_len           = 0
        phrase_boundary         = :, - , . , $
        phrase_boundary_step    = 1

    path                        = /var/db/sphinxsearch/data/topics
    source                      = torrents

    html_strip      = 1
}

index doubles: topics
{
    source          = torrents
    path            = /var/db/sphinxsearch/data/doubles
    stopwords       = /var/db/sphinxsearch/stopwords.txt
}

index posts: topics
{
    path           = /var/db/sphinxsearch/data/posts
    source         = posts
}

index delta: posts
{
    path           = /var/db/sphinxsearch/data/posts.delta
    source         = delta
}

indexer
{
    mem_limit      = 256M

	# maximum IO calls per second (for I/O throttling)
	max_iops  = 60
}

searchd
{
    listen          = 127.0.0.1:3312
    log             = /var/log/sphinxsearch/searchd.log
    query_log       = /var/log/sphinxsearch/query.log
    read_timeout    = 5
    max_children    = 40
	max_matches     = 1000
    seamless_rotate = 1
    preopen_indexes = 0
    unlink_old      = 1
    pid_file        = /var/run/sphinxsearch/searchd.pid
}